home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2001 May / macformat_103_may_2001.iso / Mac OS X Shareware / Fizilla / Chrome / toolkit.jar / content / global / dialogOverlay.js < prev    next >
Encoding:
Text File  |  2001-03-26  |  2.0 KB  |  87 lines

  1. var doOKFunction = 0;
  2. var doCancelFunction = 0;
  3. var doButton2Function = 0;
  4. var doButton3Function = 0;
  5.  
  6. // call this from dialog onload() to allow ok and cancel to call your code
  7. // functions should return true if they want the dialog to close
  8. function doSetOKCancel(okFunc, cancelFunc, button2Func, button3Func )
  9. {
  10.     //dump("top.window.navigator.platform: " + top.window.navigator.platform + "\n");
  11.     
  12.     doOKFunction = okFunc;
  13.     doCancelFunction = cancelFunc;
  14.     doButton2Function = button2Func;
  15.     doButton3Function = button3Func;
  16. }
  17.  
  18. function doOKButton()
  19. {
  20.     var close = true;
  21.     
  22.     if ( doOKFunction )
  23.         close = doOKFunction();
  24.     
  25.     if (close && top)
  26.         top.window.close();
  27. }
  28.  
  29. function doCancelButton()
  30. {
  31.     var close = true;
  32.     
  33.     if ( doCancelFunction )
  34.         close = doCancelFunction();
  35.     
  36.     if (close && top)
  37.         top.window.close();
  38. }
  39.  
  40. function doButton2()
  41. {
  42.     var close = true;
  43.     
  44.     if ( doButton2Function )
  45.         close = doButton2Function();
  46.     
  47.     if (close && top)
  48.         top.window.close();
  49. }
  50.  
  51. function doButton3()
  52. {
  53.     var close = true;
  54.     
  55.     if ( doButton3Function )
  56.         close = doButton3Function();
  57.     
  58.     if (close && top)
  59.         top.window.close();
  60. }
  61.  
  62. function moveToAlertPosition()
  63. {
  64.     var xOffset = opener.outerWidth/2 - window.outerWidth/2;
  65.     var yOffset = (opener.outerHeight *2)/10;
  66.     
  67.     xOffset  = xOffset> 0 ? xOffset : 0;
  68.     if ((opener.screenX + xOffset + window.outerWidth) > screen.availWidth)
  69.         xOffset = screen.availWidth - window.outerWidth - opener.screenX;
  70.     if((opener.screenY + yOffset + window.outerHeight) > screen.availHeight)
  71.             yOffset = screen.availHeight - window.outerHeight - opener.screenY;
  72.     xOffset = ( xOffset > 0 ) ? xOffset : 0;
  73.     yOffset = ( yOffset > 0 ) ? yOffset : 0;
  74.     window.moveTo( opener.screenX + xOffset, opener.screenY + yOffset );
  75.  
  76. }
  77.  
  78. function centerWindowOnScreen()
  79. {
  80.     var xOffset = screen.availWidth/2 - window.outerWidth/2;
  81.     var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
  82.     
  83.     xOffset = ( xOffset > 0 ) ? xOffset : 0;
  84.   yOffset = ( yOffset > 0 ) ? yOffset : 0;
  85.     window.moveTo( xOffset, yOffset);
  86. }
  87.